﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using You.Niao.ShaFa.Model;
using You.Niao.ShaFa.IDAL;
using AOP;
using Webdiyer.WebControls.Mvc;
namespace You.Niao.ShaFa.Area.Controllers
{
    public partial class SofaController : Controller
    {
        //
        // GET: /Sofa/
         public IPublish ipublish;

        public SofaController(IPublish _ipublish)
        {
            ipublish = _ipublish;
        }

        public ActionResult Index()
        {
            return View();
        }
        
        public ActionResult Create()
        {
            return View();
        }

        [AOPLogin]
        public ActionResult MeetTogether()
        {
            return View();
        }

        [AOPLogin]
        public  ActionResult Publish(string City="",int CurrentPage=1)
        {
            //当前页为1
            //CurrentPage=1

            int RowsCount=0;
            //每一页显示多少行
            int PageSize=6;
            //开始页
            int StartIndex = PageSize * (CurrentPage - 1) + 1;
            //结束页
            int EndIndex = StartIndex - 1 + PageSize;
            PublishViewModel pm = new PublishViewModel();

            pm.publishList= ipublish.GetList(City, StartIndex, EndIndex, out RowsCount).ToList();
            if (pm.publishList == null || pm.publishList.Count == 0)
            {
              return  View(pm);
            }
            pm.CurrentPageIndex = CurrentPage;
            pm.PageSize = PageSize;
            pm.TotalItemCount = RowsCount;
            return View(pm);
        }

        [AOPLogin]
        public ActionResult MySofa()
        {
            return View();
        }

        [AOPLogin]
        public ActionResult ReleaseSofa()
        {
            return View();
        }
    }
}
